package com.shop.cereshop.app.dl.logic.service.Impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;

/**
 * @description
 * @Author YF
 * @Date 日期:2021/7/11 时间:21:19
 */
public class StringToListCalendar {
    public static BigDecimal getCalendar(String jsonStr,String time){
        JSONObject jsonObject1 =JSONObject.parseObject(jsonStr);
        JSONArray jsonArray = jsonObject1.getJSONArray("priceList");
        BigDecimal marketPrice = new BigDecimal(9999);
        for (int i=0;i<jsonArray.size();i++){
            JSONObject jsonObject=jsonArray.getJSONObject(i);
            String date=jsonObject.getString("date");
            if (date.equals(time)){
                marketPrice = jsonObject.getBigDecimal("marketPrice");
                break;
            }
        }
        return marketPrice;
    }
}
